/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mantechhelpdesk.entity;

import java.io.Serializable;
import java.util.Date;
import mantechhelpdesk.dao.DbConnection;
import mantechhelpdesk.dao.UsersDao;

/**
 *
 * @author DinhThang
 */
public class Articles implements Cloneable, Serializable {

    /**
     * Persistent Instance variables. This data is directly mapped to the
     * columns of database table.
     */
    private int articleID;
    private int userID;
    private String userCreate;
    private String title;
    private String describe;
    private String mainContent;
    private Date createTime;
    private boolean isEnable;

    /**
     * Constructors. DaoGen generates two constructors by default. The first one
     * takes no arguments and provides the most simple way to create object
     * instance. The another one takes one argument, which is the primary key of
     * the corresponding table.
     */
    public Articles() {
    }

    public Articles(int ArticleIDIn) {

        this.articleID = ArticleIDIn;

    }

    /**
     * Get- and Set-methods for persistent variables. The default behaviour does
     * not make any checks against malformed data, so these might require some
     * manual additions.
     */
    public int getArticleID() {
        return this.articleID;
    }

    public void setArticleID(int ArticleIDIn) {
        this.articleID = ArticleIDIn;
    }

    public int getUserID() {
        return this.userID;
    }

    public void setUserID(int UserIDIn) {
        try {
            UsersDao usersDao = new UsersDao();
            Users users = usersDao.getObject(DbConnection.getConnection(), UserIDIn);
            if (null != users && users.getUsername().length() > 0) {
                userCreate = users.getUsername();
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        this.userID = UserIDIn;
    }

    public String getTitle() {
        return this.title;
    }

    public void setTitle(String TitleIn) {
        this.title = TitleIn;
    }

    public String getMainContent() {
        return this.mainContent;
    }

    public void setMainContent(String MainContentIn) {
        this.mainContent = MainContentIn;
    }

    public Date getCreateTime() {
        return this.createTime;
    }

    public void setCreateTime(Date CreateTimeIn) {
        this.createTime = CreateTimeIn;
    }

    public boolean getIsEnable() {
        return this.isEnable;
    }

    public void setIsEnable(boolean IsEnableIn) {
        this.isEnable = IsEnableIn;
    }

    public String getDescribe() {
        return describe;
    }

    public void setDescribe(String describe) {
        this.describe = describe;
    }

    public String getUserCreate() {
        return userCreate;
    }

    public void setUserCreate(String userCreate) {
        this.userCreate = userCreate;
    }   
    
    /**
     * setAll allows to set all persistent variables in one method call. This is
     * useful, when all data is available and it is needed to set the initial
     * state of this object. Note that this method will directly modify instance
     * variales, without going trough the individual set-methods.
     */
    public void setAll(int ArticleIDIn,
            int UserIDIn,
            String TitleIn,
            String DescribeIn,
            String MainContentIn,
            Date CreateTimeIn,
            boolean IsEnableIn) {
        this.articleID = ArticleIDIn;
        this.userID = UserIDIn;
        this.title = TitleIn;
        this.describe = DescribeIn;
        this.mainContent = MainContentIn;
        this.createTime = CreateTimeIn;
        this.isEnable = IsEnableIn;
    }

    public Articles(int ArticleIDIn,
            int UserIDIn,
            String TitleIn,
            String DescribeIn,
            String MainContentIn,
            Date CreateTimeIn,
            boolean IsEnableIn) {
        this.articleID = ArticleIDIn;
        this.userID = UserIDIn;
        this.title = TitleIn;
        this.describe = DescribeIn;
        this.mainContent = MainContentIn;
        this.createTime = CreateTimeIn;
        this.isEnable = IsEnableIn;
    }
}
